package cn.labbook.bluetooth.entity.excel;

import cn.labbook.bluetooth.entity.AmmeterReadingAmmeterView;
import lombok.Data;
import lombok.experimental.Accessors;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Accessors(chain = true)
public class AmmeterReadingAmmeterViewTemplate {
    private String ammeterId;

    private String location;

    private Double electricQuantity;

    private String readingTime;

    private Double useQuantity;

    public static AmmeterReadingAmmeterViewTemplate build(AmmeterReadingAmmeterView ammeterReadingAmmeterView) {
        AmmeterReadingAmmeterViewTemplate ammeterReadingAmmeterViewTemplate = new AmmeterReadingAmmeterViewTemplate();
        ammeterReadingAmmeterViewTemplate.setAmmeterId(ammeterReadingAmmeterView.getAmmeterId());
        ammeterReadingAmmeterViewTemplate.setElectricQuantity(ammeterReadingAmmeterView.getElectricQuantity());
        ammeterReadingAmmeterViewTemplate.setLocation(ammeterReadingAmmeterView.getLocation());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        ammeterReadingAmmeterViewTemplate.setReadingTime(sdf.format(ammeterReadingAmmeterView.getReadingTime()));
        ammeterReadingAmmeterViewTemplate.setUseQuantity(ammeterReadingAmmeterView.getUseQuantity());
        return ammeterReadingAmmeterViewTemplate;
    }
}
